--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
docs/agents/conventions/tests.md 9c739fa940d1bcaefcd5de9a3b461762a7200103 (9c739fa9) Text, 4.38 KB
Test conventions
Applies when editing T383838tests/**/*.{py,js}.
• Backend: T383838tests/backend/test_*.py with pytest + asyncio auto mode.
• Frontend: T383838tests/frontend/*.test.js with vitest + T383838@vue/test-utils.
• Mock T383838window.api for page tests. Assert toasts when outcomes are user-visible.
• Prefer focused files over full suite unless the user asks for broad runs.
• Landlock tests that apply the sandbox must run in a subprocess (one restrict per process).
• Long-running / notification soak suites can hang. Prefer timeouts and avoid piping pytest through T383838tail in agent shells.
Oracle style (no soft fuzz)
Property and fuzz tests must assert an accept or reject outcome, not only that nothing crashed.
Refuse these patterns:
• Bare T383838except Exception: pass around the code under test
• T383838never_raises tests with no postcondition
• Asserting only that a result dict has an T383838"ok" key without checking True or False
• Mocks that return the success path for every input under a security oracle
Prefer:
• Independent oracle: given input X, predict accept or reject, then assert the code matches
• Jail oracles: on success, resolved path stays under the allowed root
• Closed reason sets: on T383838ValueError, the message is one of the known machine reasons
• Round-trip or shape invariants when the API is pure parsing
Full skill: T383838docs/agents/skills/test-oracles/SKILL.md.
Path jail filesystem features: T383838docs/agents/skills/path-jail-local-fs/SKILL.md and T383838docs/agents/conventions/path-jail.md.
Exploratory bug hunting: T383838docs/agents/skills/exploratory-testing/SKILL.md.
Frontend mega-page ownership contracts
• Ownership inventory: T383838tests/frontend/fixtures/frontend_mega_page_ownership.json
• Symbol continuity: T383838tests/frontend/fixtures/frontend_symbol_continuity/
• Scanner tests: T383838tests/frontend/frontendOwnershipContract.test.js
• Extract workflow: T383838docs/agents/skills/vue-mega-page-split/SKILL.md
• Refresh ownership fixture only when inventory intentionally changes:
T383838UPDATE_FRONTEND_OWNERSHIP=1 pnpm exec vitest run tests/frontend/frontendOwnershipContract.test.js -t ownership_fixture
HTTP and WS path-scanning contracts
Route and WS manifests are discovered from source text:
• HTTP: T383838tests/backend/http_api_contract_helpers.py scans T383838meshchatx/meshchat.py and T383838meshchatx/src/backend/http/**/*.py
• WS: T383838tests/backend/ws_contract_helpers.py scans the same trees plus T383838rns_link_manager.py for link events
Fixtures:
• T383838tests/backend/fixtures/http_api_routes.json
• T383838tests/backend/fixtures/ws_message_manifest.json
Refresh only when the inventory intentionally changes:
T282828
Te6edf3UPDATE_HTTP_API_ROUTESTff7b72=T79c0ff1 uv run pytest tests/backend/test_http_api_contract.py -k meshchat_http_routes_match_fixture
Te6edf3UPDATE_WS_MESSAGE_MANIFESTTff7b72=T79c0ff1 uv run pytest tests/backend/test_ws_json_contracts.py -k manifest_matches_meshchat
JSON response schemas stay in T383838tests/backend/ (T383838api_json_contract_schemas.py, T383838http_api_response_schemas.py, registry files). See T383838docs/agents/module-ownership.md.
Extended Edge Case Tester (EECT) and Live Validation (LV)
• EECT packs live under T383838tests/backend/eect/packs/ and use marker T383838eect.
• LV ladder lives under T383838tests/backend/eect/live/ and uses marker T383838live_validation.
• Replay a failure with T383838MESHCHAT_EECT_SEED=<seed> (printed on assert failure).
• Commands: T383838task test:eect, T383838task test:lv:l0, T383838MESHCHAT_LIVE_VALIDATION=1 task test:lv.
• LV L2/L3 are opt-in (T383838MESHCHAT_LIVE_VALIDATION=1 or T383838MESHCHAT_LIVE_RETICULUM=1). L0/L1 stay CI-safe.
HTTP and WebSocket contract scanners
• HTTP route inventory: T383838tests/backend/http_api_contract_helpers.py scans
T383838meshchatx/meshchat.py and all T383838meshchatx/src/backend/http/**/*.py.
• WS message inventory: T383838tests/backend/ws_contract_helpers.py scans the same trees
(plus T383838rns_link_manager.py for T383838rns.link.* broadcasts).
• Refresh HTTP fixture only when routes intentionally change:
T383838UPDATE_HTTP_API_ROUTES=1 uv run pytest tests/backend/test_http_api_contract.py -k meshchat_http_routes_match_fixture
• Refresh WS fixture only when message types intentionally change:
T383838UPDATE_WS_MESSAGE_MANIFEST=1 uv run pytest tests/backend/test_ws_json_contracts.py -k manifest_matches_meshchat
• Domain ownership for routes vs schemas: T383838docs/agents/module-ownership.md.
• Extraction workflow: T383838docs/agents/skills/meshchat-orchestration-split/SKILL.md.
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────